home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / comm / misc / zvm1_19.lha / handlefax.zvm < prev    next >
Text File  |  1993-04-23  |  7KB  |  263 lines

  1. /* This is called to start the fax program */
  2. /* No arguments */
  3.  
  4. options failat 50
  5. address rexx_gpfax
  6. 'listen'
  7. 'recfax'
  8. 'unlisten'
  9. call listen()
  10. exit 20
  11.  
  12. /*-------------------------HANDS OFF--------------------------------------*/
  13. /* DON'T TOUCH THIS STUFF.  IF YOU FIX SOMETHING HERE, TELL ME ABOUT IT   */
  14.  
  15. /* This function gives you a simple way of presenting an N key menu
  16.     to the caller
  17.  
  18.     ARGS:  numKeys choiceFileName badChoiceFileName timeOut validChoices
  19.     numBadChoices
  20.  
  21.     numKeys = number of keys wanted
  22.     choiceFileName = file name of the menu
  23.     badChoiceFileName = what to say if caller enters a bad choice
  24.     timeOut = number of seconds allowed before timing out
  25.     validChoices = list of characters that are valid choices
  26.     numBadChoices = number of times you want to present the menu before exiting
  27.  
  28.     RETURNS:  status, choice = valid key
  29. */
  30.  
  31. presentMenu: procedure expose choice status. mode.
  32.     parse arg numKeys,choiceFileName,badChoiceFileName,timeOut,validChoices,numBadChoices .
  33.  
  34.     timesAround = numBadChoices;
  35.  
  36.     do timesAround = numBadChoices to 1 by -1
  37.         status = playVoice(choiceFileName)
  38.  
  39.         if status > status.keyDetected then signal presentMenuDone;
  40.  
  41.         status = readNKeys(numKeys, timeOut)
  42.  
  43.         if status = status.timedOut then do
  44.             call flushPhoneBuffer()
  45.             status = playVoice('voice:voices/Timed Out')
  46.             iterate
  47.         end
  48.         if status ~= status.normal then signal presentMenuDone;
  49.  
  50.         choice = keys
  51.         if pos(choice, validChoices) = 0 then do
  52.             call flushPhoneBuffer()
  53.             status = playVoice(badChoiceFileName)
  54.             iterate
  55.         end
  56.  
  57.         return status.normal
  58.     end
  59.  
  60.     status = status.timedOut
  61. presentMenuDone:
  62.     return status
  63.  
  64. /*----------------------------------------------------------------------*/
  65. /*    Here are the encapsulated functions.  They're responsible for
  66.     communicating with ZVM.  Don't edit or touch them, except for
  67.     bug fixes.
  68. */
  69.  
  70. playVoice:  procedure expose status. mode.
  71.     parse arg fileName
  72.     address voicemail1 'playVoice' fileName
  73.     return rc
  74.  
  75. addLogEntry: procedure expose status. mode.
  76.     parse arg fileName, actualTime, duration
  77.     address voicemail1 'addLogEntry' fileName ',' actualTime ',' duration
  78.     return rc
  79.  
  80. setLogEntryStatus: procedure expose status. mode.
  81.     parse arg logEntryNumber, logEntryStatus
  82.     select
  83.         when logEntryStatus = ' ' then ls = 0
  84.         when logEntryStatus = 'a' then ls = 1
  85.         when logEntryStatus = 'd' then ls = 2
  86.         otherwise ls = -1
  87.     end
  88.     address voicemail1 'setLogEntryStatus' logEntryNumber ',' ls
  89.     return rc
  90.  
  91. getLogEntryData: procedure expose status. mode.
  92.     parse arg logEntryNumber
  93.     address voicemail1 'getLogEntryData' logEntryNumber
  94.     return result
  95.  
  96. getLogEntryFileName: procedure expose status. mode.
  97.     parse arg logEntryNumber
  98.     address voicemail1 'getLogEntryFileName' logEntryNumber
  99.     return result
  100.  
  101. getNumVoiceMessages: procedure expose status. mode.
  102.     address voicemail1 'getNumVoiceMessages'
  103.     return result
  104.  
  105. recordVoice:  procedure expose status. mode.
  106.     parse arg fileName
  107.     address voicemail1 'recordVoice' fileName
  108.     return rc
  109.  
  110. password: procedure expose status. mode.
  111.     address voicemail1 'password'
  112.     return result
  113.  
  114. hasFax: procedure expose status. mode.
  115.     address voicemail1 'hasfax'
  116.     return result
  117.  
  118. playBeep:  procedure expose status. mode.
  119.     parse arg tone1, tone2, duration
  120.     address voicemail1 'playBeep' tone1 ',' tone2 ',' duration
  121.     return rc
  122.  
  123. readNKeys:  procedure expose status. keys mode.
  124.     parse arg numKeys, timeOut
  125.     address voicemail1 'readNKeys' numKeys ',' timeOut
  126.     if rc = status.normal then keys = result
  127.     return rc
  128.  
  129. read1Key:  procedure expose status. key mode.
  130.     parse arg timeOut
  131.     address voicemail1 'read1Key' timeOut
  132.     if rc = status.normal then key = result
  133.     return rc
  134.  
  135. readKeysUntil: procedure expose status. keys mode.
  136.     parse arg terminatingCharacter, maxCharacters, timeOut
  137.     address voicemail1 'readKeysUntil' terminatingCharacter ',' maxCharacters ',' timeOut
  138.     if rc = status.normal then keys = result
  139.     return rc
  140.  
  141. readLine: procedure expose status. line mode.
  142.     parse arg timeOut
  143.     address voicemail1 'readLine' timeOut
  144.     if rc = status.normal then line = result
  145.     return rc
  146.  
  147. writeLine: procedure expose status. mode.
  148.     parse arg line
  149.     address voicemail1 'writeLine' line
  150.     return rc
  151.  
  152. /* the 'assumeUnknownMode' is to make sure that any use of a voice command WILL
  153.     cause ZVM to hang up the line, reset the modem, then do its stuff */
  154.  
  155. dropLine: procedure expose status. mode.
  156.     address voicemail1 'assumeUnknownMode'
  157.     address voicemail1 'requireMode' mode.commandMode
  158.     return rc
  159.  
  160. atCommands: procedure expose status. mode.
  161.     address voicemail1 'assumeUnknownMode'
  162.     address voicemail1 'requireMode' mode.connectedMode
  163.     return rc
  164.  
  165. use19200: procedure expose status. mode.
  166.     address voicemail1 'setserial'
  167.     return rc
  168.  
  169. flushPhoneBuffer:  procedure expose status. mode.
  170.     address voicemail1 'flushPhoneBuffer'
  171.     return status.normal
  172.  
  173. listen: procedure expose status. mode.
  174.     address voicemail1 'listen'
  175.     return status.normal
  176.  
  177. answerFax: procedure expose status. mode.
  178.     address voicemail1 'answerFax'
  179.     return rc
  180.  
  181. cTime: procedure expose status. now mode.
  182.     address voicemail1 'ctime'
  183.     return result
  184.  
  185. displayError: procedure expose status. mode.
  186.     parse arg error
  187.     address voicemail1 'displayError' error
  188.     return status.normal
  189.  
  190. displayStatus: procedure expose status. mode.
  191.     parse arg status
  192.     address voicemail1 'displayStatus' status
  193.     return status.normal
  194.  
  195. /* Effectively unlistens also! */
  196. setLastError: procedure expose status. mode.
  197.     parse arg status, error
  198.     address voicemail1 'setLastError' status ',' error
  199.  
  200. /*-----------------------------------------------------------------------*/
  201. /* signal processing */
  202. error:
  203.     say "Error " rc " at line " sigl
  204.     call listen()
  205.     exit 20
  206.  
  207. break_c:
  208. halt:
  209.     say "VoiceMail was stopped manually"
  210.     call listen()
  211.     exit 20
  212.  
  213.  
  214. novalue:
  215.     say "No Value at Line" sigl
  216.     call playVoice('voice:voices/NoValue')
  217.     call listen()
  218.     exit 20
  219.  
  220. syntax:
  221.     say 'Syntax Error at Line' sigl
  222.     call playVoice('voice:voices/SyntaxError')
  223.     call listen()
  224.     exit 20
  225.  
  226.  
  227. /* Initialize everything needed to communicate correctly with ZVM */
  228. doInitializations: procedure expose compression. mode. status. device.
  229.  
  230. /* compressions */
  231. compression.ADPCM2 = 2
  232. compression.ADPCM3 = 3
  233. compression.CELP = 1
  234.  
  235. /* devices */
  236. device.telephoneLine = 2
  237. device.externalMic = 8
  238. device.internalSpeaker = 16
  239.  
  240. /* modem modes */
  241. mode.unknownMode = -1
  242. mode.commandMode = 0
  243. mode.voiceMode = 1
  244. mode.connectedMode = 2
  245. mode.playMode = 3
  246. mode.recordMode = 4
  247.  
  248. /* return statuses from the various commands */
  249. status.normal = 0
  250. status.keyDetected = 1
  251. status.quietDetected = 2
  252. status.silenceDetected = 3
  253. status.faxDetected = 4
  254. status.busyDetected = 5
  255. status.timedOut = 6
  256. status.signalDetected = 7
  257. status.overflow = 8
  258. status.error = 9
  259.  
  260. return
  261.  
  262.  
  263.